<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">


<ui:composition template="/templates/templateAdmin.xhtml">
	<ui:define name="conteudo">
		<h:form id="listar">
			<p:dataTable value="#{mBDisciplina.listaDisc}" var="disciplina" emptyMessage="Nenhuma disciplina cadastrada" rows="10" paginator="true">
				<p:column headerText="Código" filterBy="#{disciplina.codigo}" filterMatchMode="contains">
					<h:outputText value="#{disciplina.codigo}" />
				</p:column>
				<p:column headerText="Nome" filterBy="#{disciplina.nome}" filterMatchMode="contains">
					<h:outputText value="#{disciplina.nome}" />
				</p:column>
				<p:column headerText="Ações">
					<p:commandButton value="Editar" action="#{mBDisciplina.irEditar()}" ajax="false">
						<f:setPropertyActionListener target="#{mBDisciplina.disciplina}" value="#{disciplina}" />
					</p:commandButton>
					<p:commandButton value="Excluir" oncomplete="excluir.show()">
						<f:setPropertyActionListener target="#{mBDisciplina.disciplina}" value="#{disciplina}" />
					</p:commandButton>
				</p:column>
			</p:dataTable>
		</h:form>
		<p:dialog widgetVar="excluir">
			<h:form>
				<h:outputText value="Tem certeza que deseja excluir a disciplina?" />
				<p:commandButton value="Sim" action="#{mBDisciplina.remover()}" update="listar" ajax="false" oncomplete="excluir.hide()"/>
				<p:commandButton value="Não" oncomplete="excluir.hide()"/>
			</h:form>
		</p:dialog>
		<h:form>
			<p:panel header="Disciplina">
				<h:panelGrid columns="2">
					<h:outputText value="Código:" />
					<p:inputText value="#{mBDisciplina.disciplina.sigla}"/>
					<h:outputText value="Nome:" />
					<p:inputText value="#{mBDisciplina.disciplina.nome}" size="30"/>
					<h:outputText value="Ementa:" />
					<p:inputTextarea value="#{mBDisciplina.disciplina.ementa}" style="width:400px"/>
					<p:commandButton value="Cadastrar" rendered="#{!mBDisciplina.editavel}" action="#{mBDisciplina.cadastrar()}" ajax="false"/>
					<p:commandButton value="Editar" rendered="#{mBDisciplina.editavel}" action="#{mBDisciplina.editar()}" ajax="false"/>
					<p:commandButton value="Cancelar" action="#{mBDisciplina.limpar}" ajax="false"/>
				</h:panelGrid>
			</p:panel>
		</h:form>
	</ui:define>
</ui:composition>
</html>